package com.vnp.vchat.fragment;

import com.vnp.vchat.MainPanelActivity;
import com.vnp.vchat.R;
import com.vnp.vchat.util.Common;
import com.vnp.vchat.util.Utils;
import com.vnp.vchat.version2.ChungActivity;
import com.vnp.vchat.version2.HienthiActivity;
import com.vnp.vchat.version2.ThongbaoActivity;
import com.vnp.vchat.version2.ThongtincanhanActivity;

import android.content.Intent;
import android.graphics.Typeface;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class CaidatScr extends Fragment implements OnClickListener{
	
	TextView title;
	
	TextView titleThongtin, titleThongbao, titleHienthi, titleChung;
	
	RelativeLayout rlThongtin, rlThongbao, rlHienthi, rlChung;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
	}
	
	ViewGroup viewGroup;
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		if(viewGroup==null) {
			viewGroup = (ViewGroup) inflater.inflate(R.layout.scr_caidatmoi, container, false);
		} else {
			((ViewGroup) viewGroup.getParent()).removeView(viewGroup);
		}
		title = (TextView) viewGroup.findViewById(R.id.title);
		title.setTypeface(Utils.getTypefaceRegular(getActivity()),
				Typeface.BOLD);
		titleThongtin = (TextView) viewGroup.findViewById(R.id.title_thongtincanhan);
		titleThongbao = (TextView) viewGroup.findViewById(R.id.title_thongbao);
		titleHienthi = (TextView) viewGroup.findViewById(R.id.title_hienthi);
		titleChung = (TextView) viewGroup.findViewById(R.id.title_chung);
		
		rlThongtin = (RelativeLayout) viewGroup.findViewById(R.id.rl_thongtin);
		rlThongbao = (RelativeLayout) viewGroup.findViewById(R.id.rl_thongbao);
		rlHienthi = (RelativeLayout) viewGroup.findViewById(R.id.rl_hienthi);
		rlChung = (RelativeLayout) viewGroup.findViewById(R.id.rl_chung);
		
		init();
		setFont();
		return viewGroup;
	}
	
	void init(){
		title.setText("Cài đặt");
		rlThongtin.setOnClickListener(this);
		rlThongbao.setOnClickListener(this);
		rlHienthi.setOnClickListener(this);
		rlChung.setOnClickListener(this);
	}
	
	void setFont(){
		title.setTypeface(Utils.getTypefaceRegular(getActivity()),
				Typeface.BOLD);
		titleThongtin.setTypeface(Utils.getTypefaceRegular(getActivity()));
		titleThongbao.setTypeface(Utils.getTypefaceRegular(getActivity()));
		titleHienthi.setTypeface(Utils.getTypefaceRegular(getActivity()));
		titleChung.setTypeface(Utils.getTypefaceRegular(getActivity()));
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.rl_thongtin:
			
			gotoCaidatThongtinCanhan();
			break;
		case R.id.rl_thongbao:
			gotoCaidatThongbao();
			break;
		case R.id.rl_hienthi:
			gotoCaidatHienthi();
			break;
		case R.id.rl_chung:
			gotoCaidatChung();
			break;

		default:
			break;
		}
	}
	
	
	void gotoCaidatThongtinCanhan(){
		MainPanelActivity.onGoto = true;
		Intent t = new Intent(getActivity(), ThongtincanhanActivity.class);
		startActivity(t);
		getActivity().overridePendingTransition(R.anim.trans_left_in, R.anim.over_main_left);
	}
	void gotoCaidatThongbao(){
		MainPanelActivity.onGoto = true;
		Intent t = new Intent(getActivity(), ThongbaoActivity.class);
		startActivity(t);
		getActivity().overridePendingTransition(R.anim.trans_left_in, R.anim.over_main_left);
	}
	void gotoCaidatHienthi(){
		MainPanelActivity.onGoto = true;
		Intent t = new Intent(getActivity(), HienthiActivity.class);
		startActivity(t);
		getActivity().overridePendingTransition(R.anim.trans_left_in, R.anim.over_main_left);
	}
	void gotoCaidatChung(){
		MainPanelActivity.onGoto = true;
		Intent t = new Intent(getActivity(), ChungActivity.class);
		startActivity(t);
		getActivity().overridePendingTransition(R.anim.trans_left_in, R.anim.over_main_left);
	}
	
	
}
